<template>
  <div>
    <el-form ref="form" :model="form" label-width="100px">
      <el-form-item label="供应商编号">
        <el-input v-model="form.id"></el-input>
      </el-form-item>
      <el-form-item label="供应商名称">
        <el-input v-model="form.name"></el-input>
      </el-form-item>

      <el-form-item label="联系方式">
        <el-input v-model="form.phone"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">确认</el-button>
        <el-button @click="reset">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import axios from "axios";
import qs from "qs";
export default {
  data() {
    return {
      form: {
        name: "",
        id: "",
        phone: "",
      },
    };
  },
  methods: {
    onSubmit() {
      axios({
        url: "http://localhost:3000/addSupplier",
        method: "post",
        data: qs.stringify({
          name: this.form.name,
          id: this.form.id,
          phone: this.form.phone,
        }),
      });
      this.$message({
        message: "添加成功！",
        type: "success",
      })
      history.back();
    },
    reset() {
      this.$router.push("/supplier");
    },
  },
};
</script>

<style scoped>
</style>